﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XCMSData;

public partial class Admin_Admin_Article : AdminBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //输出所有SQL到日志，方便调试。
        //XCMSData.Title.SessionDBO.EnableSqlLog = true;

        if (!IsPostBack && Request.QueryString["Act"] == "Add")
            XFormView1.ChangeMode(FormViewMode.Insert);
    }

    protected void XFormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "Cancel")
        {
            goback();
        }
    }

    void goback()
    {
        String ids = Request.QueryString["TitleID"];
        int id = 0;
        if (!String.IsNullOrEmpty(ids))
        {
            int.TryParse(ids, out id);
        }

        if (id > 0)
        {
            Title t = XCMSData.Title.FindByKey(id);
            if (t != null && t.BoardID > 0)
                Response.Redirect("Admin_Title.aspx?BoardID=" + t.BoardID.ToString());
        }
        Response.Redirect("Admin_Title.aspx");
    }
    protected void XFormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
    {
        goback();
    }
    protected void XFormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        goback();
    }
}